<template>
	<view>
		<view class="page-top">
			<view class="avatar">
				<image :src="imglink + 'head-portrait.png'" mode=""></image>
			</view>
			<view class="success-tip">恭喜你，报名成功！</view>
		</view>
		<view class="main-content">
			<view class="content-list">
				<view class="content-item">
					<span>报名科目</span>
					<span>数学</span>
				</view>
				<view class="content-item">
					<span>报名科目</span>
					<span>数学</span>
				</view>
				<view class="content-item">
					<span>报名科目</span>
					<span>数学</span>
				</view>
				<view class="content-item">
					<span>报名科目</span>
					<span>数学</span>
				</view>
			</view>
			<view class="btn">
				点我0元领取198元课程
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		onLoad() {
			this.getQueryString()
			// 获取参数
			this.sub_mch_id = this.getQueryString("sub_mch_id"); //特约商户号
			console.log("sub_mch_id is " + this.sub_mch_id)
			this.out_trade_no = this.getQueryString("out_trade_no"); //商户订单号
			console.log("out_trade_no is " + this.out_trade_no)
			this.check_code = this.getQueryString("check_code"); //md5 校验码
			console.log("check_code is " + this.check_code)
			this.initPostData()
		},
		data() {
			return {
				imglink: this.$store.state.imgLink,
				sub_mch_id: null,
				out_trade_no: null,
				check_code: null,
			}
		},
		methods: {
			// 获取页面返回参数
			getQueryString(name) {
				let query = window.location.search.substring(1)
				let vars = query.split("&");
				for (var i = 0; i < vars.length; i++) {
					var pair = vars[i].split("=");
					if (pair[0] == name) {
						return pair[1];
					}
				}
				return null;
			},
			// 初始化小票
			initPostData() {
				let initData = {
					action: 'onIframeReady',
					displayStyle: 'SHOW_CUSTOM_PAGE'
				}
				let initPostData = JSON.stringify(initData)
				window.parent.postMessage(initPostData, 'https://payapp.weixin.qq.com')
			}
		}
	}
</script>

<style scoped>
	page {
		width: 100vw;
	}

	.page-top {
		display: flex;
		flex-direction: column;
		align-items: center;
		margin-top: 80rpx;
	}

	.page-top .avatar image {
		height: 140rpx;
		width: 140rpx;
		border-radius: 50%;
	}

	.page-top .success-tip {
		font-size: 32rpx;
		color: #F96b4e;
		font-weight: bold;
	}

	.main-content .content-list {
		background-color: #F5F5F5;
		border-radius: 10rpx;
		width: 690rpx;
		margin: 40rpx auto;
		padding: 40rpx;
		box-sizing: border-box;
		color: #333;
		font-size: 28rpx;
	}

	.main-content .content-list .content-item {
		display: flex;
		justify-content: space-between;
	}

	.main-content .content-list .content-item:not(:last-child) {
		margin-bottom: 20rpx;
	}

	.main-content .btn {
		background: rgba(249, 107, 78, 0.95);
		border-radius: 44rpx;
		font-size: 32rpx;
		color: #FFFFFF;
		height: 80rpx;
		width: 638rpx;
		line-height: 80rpx;
		text-align: center;
		margin: 0 auto;
	}
</style>
